<?php defined('BYshopJL') or exit('Access Invalid!'); ?>

<div class="tabmenu">
    <?php include template('layout/submenu'); ?>
</div>
<form method="get" action="index.php">
    <table class="search-form">
        <input type="hidden" name="act" value="store_wx_index" />
        <input type="hidden" name="op" value="add_goods_index" />
        <tr>
            <td>&nbsp;</td>
            <th><?php echo $lang['store_goods_index_store_goods_class'];?></th>
            <td class="w160"><select name="stc_id" class="w150">
                    <option value="0"><?php echo $lang['nc_please_choose'];?></option>
                    <?php if(is_array($output['store_goods_class']) && !empty($output['store_goods_class'])){?>
                        <?php foreach ($output['store_goods_class'] as $val) {?>
                            <option value="<?php echo $val['stc_id']; ?>" <?php if ($_GET['stc_id'] == $val['stc_id']){ echo 'selected=selected';}?>><?php echo $val['stc_name']; ?></option>
                            <?php if (is_array($val['child']) && count($val['child'])>0){?>
                                <?php foreach ($val['child'] as $child_val){?>
                                    <option value="<?php echo $child_val['stc_id']; ?>" <?php if ($_GET['stc_id'] == $child_val['stc_id']){ echo 'selected=selected';}?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['stc_name']; ?></option>
                                <?php }?>
                            <?php }?>
                        <?php }?>
                    <?php }?>
                </select></td>
            <th> <select name="search_type">
                    <option value="0" <?php if ($_GET['type'] == 0) {?>selected="selected"<?php }?>><?php echo $lang['store_goods_index_goods_name'];?></option>
                    <option value="1" <?php if ($_GET['type'] == 1) {?>selected="selected"<?php }?>><?php echo $lang['store_goods_index_goods_no'];?></option>
                    <option value="2" <?php if ($_GET['type'] == 2) {?>selected="selected"<?php }?>>平台货号</option>
                </select>
            </th>
            <td class="w160"><input type="text" class="text w150" name="keyword" value="<?php echo $_GET['keyword']; ?>"/></td>
            <td class="tc w70"><label class="submit-border">
                    <input type="submit" class="submit" value="<?php echo $lang['nc_search'];?>" />
                </label></td>
        </tr>
    </table>
</form>
<table class="ncsc-default-table">
    <thead>
    <tr nc_type="table_header">
        <th class="w30">&nbsp;</th>
        <th class="w50">&nbsp;</th>
        <th coltype="editable" column="goods_name" checker="check_required"
            inputwidth="230px"><?php echo $lang['store_goods_index_goods_name']; ?></th>
        <th class="w100"><?php echo $lang['store_goods_index_price']; ?></th>
        <th class="w100"><?php echo $lang['store_goods_index_stock']; ?></th>
        <th class="w100"><?php echo $lang['store_goods_index_add_time']; ?></th>
        <th class="w120"><?php echo $lang['nc_handle']; ?></th>
    </tr>
    <?php if (!empty($output['goods_list'])) { ?>
        <tr>
            <td class="tc"><input type="checkbox" id="all" class="checkall"/></td>
            <td colspan="20">
                <label for="all"><?php echo $lang['nc_select_all']; ?></label>
                <a href="javascript:void(0);" class="ncsc-btn-mini" nc_type="batchbutton"
                   uri="<?php echo urlShop('store_wx_index', 'add_goods'); ?>" name="goods_id"
                   confirm="<?php echo '添加'; ?>">
                    <?php echo '添加'; ?>
                </a>
            </td>
        </tr>
    <?php } ?>
    </thead>
    <tbody>
    <?php if (!empty($output['goods_list'])) { ?>
        <?php foreach ($output['goods_list'] as $val) { ?>
            <tr>
                <th class="tc"><input type="checkbox" class="checkitem tc" <?php if (in_array($val['goods_id'],$output['goods_id_array'])) {?>disabled="disabled"<?php }?>
                                      value="<?php echo $val['goods_id']; ?>"/></th>
                <th colspan="20">平台货号：<?php echo $val['goods_commonid']; ?></th>
            </tr>
            <tr>
                <td class="trigger"><i class="tip icon-plus-sign" nctype="ajaxGoodsList"
                                       data-comminid="<?php echo $val['goods_commonid']; ?>"
                                       title="点击展开查看此商品全部规格；规格值过多时请横向拖动区域内的滚动条进行浏览。"></i></td>
                <td>
                    <div class="pic-thumb"><a
                            href="<?php echo urlShop('goods', 'index', array('goods_id' => $val['goods_id'])); ?>"
                            target="_blank"><img src="<?php echo thumb($val, 60); ?>"/></a></div>
                </td>
                <td class="tl">
                    <dl class="goods-name">
                        <dt style="max-width: 450px !important;">
                            <?php if ($val['is_virtual'] == 1) { ?>
                                <span class="type-virtual" title="虚拟兑换商品">虚拟</span>
                            <?php } ?>
                            <?php if ($val['is_fcode'] == 1) { ?>
                                <span class="type-fcode" title="F码优先购买商品">F码</span>
                            <?php } ?>
                            <?php if ($val['is_presell'] == 1) { ?>
                                <span class="type-presell" title="预先发售商品">预售</span>
                            <?php } ?>
                            <?php if ($val['is_appoint'] == 1) { ?>
                                <span class="type-appoint" title="预约销售提示商品">预约</span>
                            <?php } ?>
                            <a href="<?php echo urlShop('goods', 'index', array('goods_id' => $val['goods_id'])); ?>"
                               target="_blank"><?php echo $val['goods_name']; ?></a></dt>
                        <dd><?php echo $lang['store_goods_index_goods_no'] . $lang['nc_colon']; ?><?php echo $val['goods_serial']; ?></dd>
                        <dd class="serve"><span class="<?php if ($val['goods_commend'] == 1) {
                                echo 'open';
                            } ?>" title="店铺推荐商品"><i class="commend">荐</i></span> <span
                                class="<?php if ($val['mobile_body'] != '') {
                                    echo 'open';
                                } ?>" title="手机端商品详情"><i class="icon-tablet"></i></span> <span class="" title="商品页面二维码"><i
                                    class="icon-qrcode"></i>
            <div class="QRcode"><a target="_blank"
                                   href="<?php echo goodsQRCode(array('goods_id' => $val['goods_id'], 'store_id' => $_SESSION['store_id'])); ?>">下载标签</a>

                <p>
                    <img
                        src="<?php echo goodsQRCode(array('goods_id' => $val['goods_id'], 'store_id' => $_SESSION['store_id'])); ?>"/>
                </p>
            </div>
            </span>
                            <?php if ($val['is_fcode'] == 1) { ?>
                                <span><a class="ncsc-btn-mini ncsc-btn-red"
                                         href="<?php echo urlShop('store_goods_online', 'download_f_code_excel', array('commonid' => $val['goods_commonid'])); ?>">下载F码</a></span>
                            <?php } ?>
                        </dd>
                    </dl>
                </td>
                <td><span><?php echo $lang['currency'] . $val['goods_price']; ?></span></td>
                <td><span <?php if ($val['goods_storage_alarm'] != 0 && $val['goods_storage'] <= $val['goods_storage_alarm']) {
                        echo 'style="color:red;"';
                    } ?>><?php echo $val['goods_storage'] . $lang['piece']; ?></span>
                </td>
                <td class="goods-time"><?php echo @date('Y-m-d', $val['goods_addtime']); ?></td>
                <td class="nscs-table-handle">
                    <?php if (in_array($val['goods_id'],$output['goods_id_array'])) {?>
                        <span><a href="javascript:void(0);" class="btn-red">
                                <p>已添加</p>
                            </a></span>
                    <?php }else{?>
                    <span><a href="javascript:void(0);" onclick="ajax_get_confirm('<?php echo '添加';?>', '<?php echo urlShop('store_wx_index', 'add_goods', array('goods_id' => $val['goods_id']));?>');" class="btn-red">
                            <p><?php echo '添加';?></p>
                        </a></span>
                    <?php }?>
                </td>
            </tr>
            <tr style="display:none;">
                <td colspan="20">
                    <div class="ncsc-goods-sku ps-container"></div>
                </td>
            </tr>
        <?php } ?>
    <?php } else { ?>
        <tr>
            <td colspan="20" class="norecord">
                <div class="warning-option"><i
                        class="icon-warning-sign"></i><span><?php echo $lang['no_record']; ?></span></div>
            </td>
        </tr>
    <?php } ?>
    </tbody>
    <tfoot>
    <?php if (!empty($output['goods_list'])) { ?>
        <tr>
            <th class="tc"><input type="checkbox" id="all2" class="checkall"/></th>
            <th colspan="10"><label for="all2"><?php echo $lang['nc_select_all']; ?></label>
                <a href="javascript:void(0);" class="ncsc-btn-mini" nc_type="batchbutton"
                   uri="<?php echo urlShop('store_wx_index', 'add_goods'); ?>" name="commonid"
                   confirm="<?php echo '添加'; ?>">
                    <?php echo '添加'; ?>
                </a>
            </th>
        </tr>
        <tr>
            <td colspan="20">
                <div class="pagination"> <?php echo $output['show_page']; ?> </div>
            </td>
        </tr>
    <?php } ?>
    </tfoot>
</table>
<script src="<?php echo RESOURCE_SITE_URL; ?>/js/jquery.poshytip.min.js"></script>
<script src="<?php echo SHOP_RESOURCE_SITE_URL; ?>/js/store_goods_list.js"></script>
<script>
    $(function () {
        //Ajax提示
        $('.tip').poshytip({
            className: 'tip-yellowsimple',
            showTimeout: 1,
            alignTo: 'target',
            alignX: 'center',
            alignY: 'top',
            offsetY: 5,
            allowTipHover: false
        });
        $('a[nctype="batch"]').click(function () {
            if ($('.checkitem:checked').length == 0) {    //没有选择
                showDialog('请选择需要操作的记录');
                return false;
            }
            var _items = '';
            $('.checkitem:checked').each(function () {
                _items += $(this).val() + ',';
            });
            _items = _items.substr(0, (_items.length - 1));

            var data_str = '';
            eval('data_str = ' + $(this).attr('data-param'));

            if (data_str.sign == 'jingle') {
                ajax_form('ajax_jingle', '设置广告词', data_str.url + '&commonid=' + _items + '&inajax=1', '480');
            } else if (data_str.sign == 'plate') {
                ajax_form('ajax_plate', '设置关联版式', data_str.url + '&commonid=' + _items + '&inajax=1', '480');
            }
        });
    });
</script>